home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 6
/
006.d81
/
pps #11
< prev
next >
Wrap
Text File
|
2022-08-26
|
3KB
|
178 lines
PEEKs, POKEs, and SYSes -- Part 11
by Jimmy Weiler
======================================
Location:51-52 Hexadecimal: $0033-34
Official Label: FRETOP Type: RAM
Useful BASIC commands: PEEK, POKE
======================================
Location 55-56 Hexadecimal: $0037-38
Official Label: MEMSIZ Type: RAM
Useful BASIC commands: PEEK, POKE
======================================
MEMSIZ and FRETOP can be used to chop
the top off of BASIC RAM to make room
for your machine language code or
sprites.
Let's start with a diagram to show
how these locations are used, then
I'll follow with an explanation.
This is a chart of the top of RAM
after your program has used three
string variables.
40960 ------------------ <---MEMSIZ
!the first string!
!used by your pro! s
!gram is here....! t
------------------ r
40912 !the second strin! v i
!g is just below ! a n
!the first string! r g
------------------ s i
40864 !and this is the ! t a
!third and last s! a b
!tring your progr! c l
!am used. Notice! k e
!that each subseq!
!uent string is p!
!laced just below!
!the previous one!
40736 ------------------ <---FRETOP
MEMSIZE points to the highest RAM
memory location available to your
program for variable storage.
Normally PEEK(55)+PEEK(56)*256 will
equal 40960, so normally string
variables will be stored downward from
that address.
FRETOP points to the TOP of the FREE
RAM (RAM that doesn't have any
variables stored in it yet). Every
time another string variable is tacked
onto the bottom of the string variable
stack, FRETOP drops to the bottom of
that latest variable. That happens
every time you assign any string.
[LET A$=B$:C$=MID$(B$,4):M$=CHR$(13)]
So what good is all this? For
normal, healthy people, no good at
all. But for us hackers, it's the
answer to our question, 'Where can I
put my binary stuff where my BASIC
program won't trounce it?'
If you've discovered the available
RAM at location 49152, you've probably
already filled it with machine code
several times over. You've probably
even put code in the cassette buffer
at 828 to 1023.
If you put your binary stuff low in
memory (near 2049), then your BASIC
program will load right on top of it
(unless you know how to mess with
TXTTAB [43-44] -- but that's another
peeks, pokes, & sys article).
If you put your binary stuff
somewhere in the middle of BASIC RAM,
there's a CHANCE nothing will get
stored into it, but why take chances?
That leaves..... the top of BASIC
RAM. To use that space you need to
know how to move FRETOP and MEMSIZ up
and down at will.
This example moves FRETOP and
MEMSIZ down to address 24576. You can
use ANY RAM address from 2051 to
40960. Just remember that if you
don't leave enough room between 2049
and MEMSIZ for your program AND its
variables you will get an OUT OF
MEMORY error.
======== continued in Part 12 ========